package com.qidian.mes.cal.controller;

import com.qidian.mes.cal.mapper.CalPlanMapper;
import com.qidian.mes.cal.service.CalPlanService;
import com.qidian.mes.pojo.cal.CalPlan;
import com.qidian.mes.pojo.cal.CalTeam;
import com.qidian.mes.pojo.cal.CalTeamMember;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 04冯虹丹
 * @Company 起点编程
 * @Time 2023/10/31 11:40
 * @Description
 */
@RestController
@CrossOrigin
@RequestMapping("/calPlan")
public class CalPlanController {
    @Autowired
    private CalPlanService calPlanService;

    /**
     * 分页查询
     * @param page
     * @param limit
     * @param calPlan
     * @return
     */
    @GetMapping("/list")
    public MESResult list(@RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10") int limit,CalPlan calPlan){
        System.out.println("startDate="+calPlan.getStartDate());
        return calPlanService.list(page,limit,calPlan);
    }


    /**
     * 单个删除
     * @param planId
     * @return
     */
    @DeleteMapping("/{planId}")
    public MESResult delete(@PathVariable Long planId){
        return calPlanService.delete(planId);
    }

    /**
     * 批量删除
     * @param planId
     * @return
     */
    @DeleteMapping("/deletes")
    public MESResult deletes(Long [] planId){
        return calPlanService.deletes(planId);
    }

    /**
     * 添加排班计划
     * @param calPlan
     * @return
     */
    @PostMapping("/save")
    public MESResult save(@RequestBody CalPlan calPlan) {
        return calPlanService.save(calPlan);
    }

    /**
     * 根据Id查询
     * @param planId
     * @return
     */
    @GetMapping("/get")
    public MESResult get(Long planId){
        return calPlanService.get(planId);
    };

    /**
     * 编辑排班计划
     * @param calPlan
     * @return
     */
    @PutMapping("/update")
    public MESResult update(@RequestBody CalPlan calPlan){
        return calPlanService.update(calPlan);
    }

}
